package com.xfp.pojo.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageDto {
    @ApiModelProperty("当前页码")
    @NotBlank(message = "页码不能为空")
    public Integer pageIndex = 1;
    @ApiModelProperty("每页显示多少条数据")
    @NotBlank(message = "每页显示条数不能为空")
    public Integer pageSize = 2;

    public void check() throws Exception {
        if(pageIndex <=0){
            pageIndex = 1;
        }
        if(pageSize<=0){
            pageSize = 5;
        }
        if(pageSize>100){
            pageSize = 100;
        }
    }
}
